import React from 'react';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/lib/locale/zh_CN';
import 'antd/dist/antd.less';
import MainLayout from './layouts/MainLayout';

class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }

  static getDerivedStateFromError(error) {
    return { hasError: true };
  }

  componentDidCatch(error, errorInfo) {
    console.error('Error caught by ErrorBoundary:', error, errorInfo);
  }

  render() {
    if (this.state.hasError) {
      return <h1>Something went wrong. Please check the console for details.</h1>;
    }

    return this.props.children;
  }
}

// Ant Design 4.x 项目基础配置
function App() {
  return (
    <ErrorBoundary>
      <ConfigProvider locale={zhCN}>
        <MainLayout />
      </ConfigProvider>
    </ErrorBoundary>
  );
}

export default App; 